package KiemTra;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JPanel;

public class ThreadButtom extends Thread{

	JPanel canvas = new JPanel();
	
	public ThreadButtom(JPanel c){
		canvas = c;
	}
	
	@Override
	public void run() {
		int ct = 200;
		int i = ct;

		while(true){
			Graphics g = canvas.getGraphics();
			Color c = new Color((int)(255.0*Math.random()),
								(int)(255.0*Math.random()),
								(int)(255.0*Math.random()));
			g.setColor(c);
			
			while(i >= 0){			
				int kc = (ct - i) * 2;
				g.drawLine(i, kc + i, kc + i, kc + i);				
				i--;
				try{ 
					Thread.sleep(10);
				}
				catch(Exception e){}	
			}

			c = new Color((int)(255.0*Math.random()),
					(int)(255.0*Math.random()),
					(int)(255.0*Math.random()));
			g.setColor(c);
			
			while(i <= ct){				
				int kc = (ct - i) * 2;				
				g.drawLine(i, kc + i, kc + i, kc + i);				
				i++;
				try{ 
					Thread.sleep(10);
				}
				catch(Exception e){}	
			}
		}		
	}

}
